import mockjs from 'mockjs';
const datalist = mockjs.mock({
    code: 200,
    msg: '学员列表加载成功',
    'data|100': [
        {
            ID: '@uuid',
            name: '@cname',
            score: '@integer(50,100)',
            city: '@city',
            time: '@date'
        }

    ]
})
export default {
    // 使用 mockjs 等三方库
    'GET /api/stu': datalist,
    'DELETE /api/stu': (req, res) => {
        let { id } = req.query
        for (let i = 0; i < datalist.data.length; i++) {
            if (datalist.data[i].ID == id) {
                datalist.data.splice(i, 1);
                res.send({
                    code: 200,
                    msg:  `${id}删除ok`
                })
                return;
            }
        }
        res.send({
            code: 100,
            msg: '未找到相应数据'
        })
    }
};